<!DOCTYPE HTML>
<html th:with="title='新增分类'">
<head th:include="fragments/header :: header">
</head>
<body id="app">
	<div class="page-container">
		<form action="/manager/market/save" method="post" class="form form-horizontal" id="form">
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					名称：
				</label>
				<div class="formControls col-xs-2 col-sm-2">
					<input type="text" class="input-text size-L" id="name" name="name">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					分类图片：
				</label>
				<input type="hidden" id="backgroundImg" name="image">
				<div class="col-xs-2 col-sm-2 col-xs-offset-4 col-sm-offset-4" style="margin: 0;">
					<div id="uploader-demo">
						<!--用来存放item-->
						<div id="fileList" class="uploader-list"></div>
						<div id="filePicker" class="btn btn-primary size-L radius ">选择图片</div>
					</div>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					类型：
				</label>
				<div class="formControls col-xs-2 col-sm-2">
					<span class="select-box">
						<select class="select size-L" id="type" name="type">
							<option value="0">广投墙广告分类</option>
				          <option value="1" >新零售广告分类</option>
						</select>
					</span>
				</div>

			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<input class="btn btn-primary size-L radius" type="submit" value="提交">
					<input class="btn btn-primary size-L radius" type="button" onclick="closeWin()" value="关闭">
				</div>
			</div>
		</form>
	</div>

	<script type="text/javascript">
		function closeWin() {
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		}
		var app = new Vue({
			el : '#app',
			data : {
				roles : []
			}
		});
		$(function() {
			$("#form").validate({
				rules : {
					name : {
						required : true
					}
				},
				onkeyup : false,
				focusCleanup : true,
				success : "valid",
				submitHandler : function(form) {
					var data = $('#form').serialize();
					$.ajax({
						type : "POST",
						url : '/manager/adsclassify/save',
						data : data,
						beforeSend : function() {

						},
						complete : function() {

						},
						error : function(request) {
							layer.alert("系统出错");
						},
						success : function(data) {
							if (data.status == 0) {
								refreshUParentList();
								layer.alert(data.message, function() {
									var index = parent.layer.getFrameIndex(window.name);
									parent.layer.close(index);
								});
							} else {
								layer.alert(data.message);
							}
						}
					});
				}
			});
		});
		$(function() {
		});
	</script>
</body>
</html>